package com.powernode.ssm.service.impl;

import com.powernode.ssm.bean.Vip;
import com.powernode.ssm.repository.VipMapper;
import com.powernode.ssm.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VipServiceImpl implements VipService {

    @Autowired
    private VipMapper vipMapper;
    @Override
    public Vip findByCardNumber(String cardNumber) {
        return vipMapper.selectByCardNumber(cardNumber);
    }

    @Override
    public Vip findById(Long id) {
        return vipMapper.selectByPrimaryKey(id);
    }

    @Override
    public void add(String name,String cardNumber,String birth) {
        Vip vip = new Vip(name,cardNumber,birth);
        vipMapper.insert(vip);
    }

    @Override
    public void delete(Long id) {
        vipMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Vip> findAll() {
        return vipMapper.selectAll();
    }
}
